package com.kerwin.event;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;

public class Main {

    public static void main(String[] args){
        System.out.println("main start!");
        Isolate.eventQueue.offer(new Timer(){
            @Override
            public void run() {
                System.out.println("timer - event - A");
                Isolate.scheduleMicrotasks.offer(new ScheduleMicrotask(){
                    @Override
                    public void run() {
                        System.out.println("ScheduleMicrotask - A - in Timer A");
                        try {
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                });

                Isolate.scheduleMicrotasks.offer(new ScheduleMicrotask(){
                    @Override
                    public void run() {
                        System.out.println("ScheduleMicrotask - B - in Timer A");
                    }
                });
            }
        });

        Isolate.scheduleMicrotasks.offer(new ScheduleMicrotask(){
            @Override
            public void run() {
                System.out.println("ScheduleMicrotask - C - in MAIN ");

                Isolate.eventQueue.offer(new Timer(){
                    @Override
                    public void run() {
                        System.out.println("timer - event - B - in ScheduleMicrotask - C ");
                    }
                });
            }
        });


        System.out.println("main end!");

    }

}
